<?php 
define('CACHE_ROOT',substr(dirname(__FILE__),0,-9).'open/demo/caches'.DIRECTORY_SEPARATOR);

$data = [];
$_POST['info'][0]['entity_name'] = '郜振宇_100';
$_POST['info'][0]['latitude'] = 39.989715;
$_POST['info'][0]['longitude'] = 116.437039;
$_POST['info'][0]['loc_time'] = 1525232703;
$_POST['info'][0]['coord_type_input'] = 'wgs84';
$_POST['info'][0]['speed'] = 27.23;
$_POST['info'][0]['direction'] = 178;
$_POST['info'][0]['height'] = 173.3;
$_POST['info'][0]['radius'] = 32;

$_POST['info'][1]['entity_name'] = '郜振宇_100';
$_POST['info'][1]['latitude'] = 39.895895;
$_POST['info'][1]['longitude'] = 116.235244;
$_POST['info'][1]['loc_time'] = 1525232703;
$_POST['info'][1]['coord_type_input'] = 'wgs84';
$_POST['info'][1]['speed'] = 27.23;
$_POST['info'][1]['direction'] = 178;
$_POST['info'][1]['height'] = 173.3;
$_POST['info'][1]['radius'] = 32;

//print_R(json_encode($_POST));DIE;
$data['point_list'] = $_POST['info'];
$time = date("G:i:s",time());
$log = "---------- $time  -----------\n";
$log .= '$data = '.var_export($_POST, true).';';
logCron('localhost_testInfo.',$log);
print_r($_POST);die;
$info  = add($data);
function add($data = []){
	$url = 'http://yingyan.baidu.com/api/v3/track/addpoints';
	$curl = curl_init();
	$data['ak'] = 'PfIOOKtAPpf91ksRfecNyGzQsCa9h2jy';
    $data['service_id'] = '203049';
	curl_setopt ($curl, CURLOPT_URL, $url);  
    curl_setopt ($curl, CURLOPT_REFERER, "http://oa.fc62.com/");  
	curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
	curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
	curl_setopt($curl,CURLOPT_POST,true); // post传输数据
	curl_setopt($curl,CURLOPT_POSTFIELDS,$data);// post传输数据
	$output = curl_exec($curl);
	//var_dump( curl_error($curl) );//如果执行curl过程中出现异常，可打开此开关，以便查看异常内容
	curl_close($curl);
	return json_decode($output,true);
}
function logCron($filename,$log){
	$file = CACHE_ROOT.$filename. date('YmdGIS').'.log.php';
	if(!is_file($file)) $log = "<?php\n die();\n" . $log;
	$fp = fopen($file, "a");
	fwrite($fp, $log);
	fclose($fp);
}
print_R($info);die;
?>